<?php

class Html_Render_Radio
{
	
	public function render($element)
	{
		/**
		 * get all options
		 */
		$multi = $element -> getMultiOptions();
		
		$name = $element -> getName();
        
		$xhtml = array();
		
		$value = $element -> getValue();
		
		
		$isMulti = is_array($value) && !is_string($value);
		
		
		foreach ($multi as $key => $label)
		{
			
			$xhtml[] = sprintf('<label><input type="radio" name="%s" %s value="%s" />%s</label>', $name, $isMulti?(in_array($key,$value)?'checked="checked"':''):($key==$value?'checked="checked"':''), $key, $label);
		}
		
		$glue = $element -> getMeta('glue', '&nbsp;&nbsp;&nbsp;&nbsp;');
		return implode($glue, $xhtml);
	}

}
